package storyforkids.io;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import android.net.Uri;
import android.os.Environment;
import android.util.Log;

public class StatementsManager {
	
	public List<String> statements = null;
	public int i;

	public List<String> initStatements(String path){
		statements = new ArrayList<String>();
		i=-1;
		try{
			File f = new File(path);
		   FileInputStream fileIS = new FileInputStream(f);
		   BufferedReader buf = new BufferedReader(new InputStreamReader(fileIS));
		   String readString = new String(); 
		   while((readString = buf.readLine())!= null){
			   if (!readString.trim().equals(""))
				   statements.add(readString);
//			   Log.v("MyDebug",readString);
		   }
		} catch (FileNotFoundException e) {
		   e.printStackTrace();
		} catch (IOException e){
		   e.printStackTrace();
		}
		return statements;
	}
	
	
	public String next(){
		i++;
		if (i>=statements.size()) i=statements.size()-1;
		return statements.get(i);
	}
	
	public String back(){
		i--;
		if (i<0) i=0;
		return statements.get(i);
	}
	
	
	
	public int getCurrentPage(){
		return i;
	}


	public void setCurrentPage(int currentPage) {
		i = currentPage;
	}
	
	
}
